package com.b2bpsssm.controller.sysmanage;/**
 * @author JunYu
 * @create 2022-08-13--16:00
 */

import com.b2bpsssm.common.R;
import com.b2bpsssm.pojo.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: B2BPSSMSystem
 * @description: 个人信息模块的控制器
 * @author: JunYu
 * @create: 2022-08-13 16:00
 **/
@Controller
@EnableSwagger2
@RequestMapping(value = "/sys_self")
@Api(value = "个人信息管理", tags = "个人信息管理api")
public class SelfController {
    //查看当前员工信息
    @RequestMapping(value = "/findSelf", method = RequestMethod.GET)
    @ResponseBody
    //Swagger配置
    @ApiOperation(value = "查看当前员工信息", notes = "通过传入员工id查看对应员工信息", httpMethod = "get", response =R.class)
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id", value = "员工id", paramType = "int", dataType = "String" , required = true)
            }
    )
    public R findSelf(@RequestParam("id") int id) {
        R r = new R();
        r.setCode(200);
        r.setMassage("查看当前员工信息，当前员工编号为" + id);
        return r;
    }

    //修改个人信息
    @RequestMapping(value = "/updateSelfInfo", method = RequestMethod.POST)
    @ResponseBody
    //Swagger配置
    @ApiOperation(value = "修改个人信息", notes = "更加员工id更改员工信息", httpMethod = "post", response =R.class)
    public R updateSelfInfo(@RequestBody SysUser sysUser) {
        R r = new R();
        r.setCode(200);
        r.setMassage("修改信息成功，修改后的员工信息为" + sysUser);
        return r;
    }

    //修改个人密码
    @RequestMapping(value = "/updateSelfPassword", method = RequestMethod.POST)
    @ResponseBody
    //Swagger配置
    @ApiOperation(value = "修改个人密码", notes = "根据角色id更改密码", httpMethod = "post", response =R.class)
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "password", value = "新密码", paramType = "String", dataType = "String", required = true)
            }
    )
    public R updateSelfPassword(String password) {
        System.out.println(password);
        R r = new R();
        r.setCode(200);
        r.setMassage("修改密码成功");
        return r;
    }
}
